﻿namespace Murry.DietTracker.Model
{
    /// <summary>
    /// MongoDB implementation of IDietaryReferenceIntakeFilterSpec
    /// </summary>
    public class DietaryReferenceIntakeFilterSpec
    {
        ///// <summary>
        ///// Constructor.
        ///// </summary>
        //public DietaryReferenceIntakeFilterSpec()
        //{
        //    Query = from c in TheDataStore.QueryAll<IDietaryReferenceIntake>()
        //            where c.MinAge >= Age && c.MaxAge < Age &&
        //            (c.GenderScope == Gender || c.GenderScope == GenderScope.NotGenderSpecific) &&
        //            (c.PregnancyScope == Pregnant || c.PregnancyScope == PregnancyScope.Unspecified) &&
        //            (c.LactatingScope == Lactating || c.LactatingScope == LactatingScope.Unspecified)
        //            select c;
        //}

        //private object Query { get; set; }

        /// <summary>
        /// Age in years.
        /// </summary>
        public double Age { get; set; }

        /// <summary>
        /// Gender Scope.
        /// </summary>
        public GenderScope Gender { get; set; }

        /// <summary>
        /// Pregnant.
        /// </summary>
        public PregnancyScope Pregnant { get; set; }

        /// <summary>
        /// Lactating.
        /// </summary>
        public LactatingScope Lactating { get; set; }

        ///// <summary>
        ///// Get the MongoQuery for this filter spec.
        ///// </summary>
        //public object Filter
        //{
        //    get
        //    {
        //        if (Age < 0 || Age > 120)
        //        {
        //            throw new InvalidOperationException();
        //        }

        //        if (Gender == GenderScope.NotGenderSpecific)
        //        {
        //            throw new InvalidOperationException();
        //        }

        //        if (Pregnant == PregnancyScope.Unspecified)
        //        {
        //            throw new InvalidOperationException();
        //        }

        //        if (Lactating == LactatingScope.Unspecified)
        //        {
        //            throw new InvalidOperationException();
        //        }
                
        //        return Query;
        //    }
        //}
    }
}
